package com.mounir.hadoop.mymongodb;

import java.net.UnknownHostException;
import java.util.Arrays;

import com.mongodb.DB;
import com.mongodb.MongoClient;
import com.mongodb.ServerAddress;

public class MyMongoDB {

	public static void main(String[] arg) {
		// To directly connect to a single MongoDB server (note that this will
		// not auto-discover the primary even
		// if it's a member of a replica set:
		MongoClient mongoClient;
		try {
			mongoClient = new MongoClient();
			// or
			MongoClient mongoClient2 = new MongoClient("localhost");
			// or
			MongoClient mongoClient3 = new MongoClient("localhost", 27017);
			// or, to connect to a replica set, with auto-discovery of the
			// primary, supply a seed list of members
			MongoClient mongoClient4 = new MongoClient(Arrays.asList(
					new ServerAddress("localhost", 27017), new ServerAddress(
							"localhost", 27018), new ServerAddress("localhost",
							27019)));

			DB db = mongoClient.getDB("mounir");
			System.out.println(db);
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
